home *** CD-ROM | disk | FTP | other *** search
/ PC World Interactive 9 / PC World Interactive 9 - Temmuz 1998.iso / share / internet / hot / cgi.z / rand_lnk.pl < prev    next >
Perl Script  |  1997-06-20  |  965b  |  35 lines

  1. #! /bin/perl
  2. ##############################################################################
  3. # Random Link Generator
  4. # Created By Matt Wright
  5. # Version 1.0
  6. # Created on 7/15/95            Last Modified On 7/30/95
  7. # I can be reached at:          mattw@misha.net
  8. # Scripts Found at:             http://worldwidemart.com/scripts/
  9. # The file README contains more information and installation instructions.
  10.  
  11. # Define Variables
  12. $linkfile = "/home/youruserid/public_html/database";
  13.  
  14. # Options
  15. $uselog = 0;            # 1 = YES; 0 = NO
  16.    $logfile = "/home/youruserid/public_html/rand_log";
  17.  
  18. $date = `date +"%D"`; chop($date);
  19.  
  20. open (LINKS, "$linkfile");
  21.  
  22. srand();                        # kick rand
  23. $nlines=@file=<LINKS>;          # inhale file & get # of lines
  24. print "Location: $file[int rand $nlines]\n\n";  # print a random line
  25.  
  26. close (LINKS);
  27.  
  28. if ($uselog eq '1') {
  29.    open (LOG, ">>$logfile");
  30.    print LOG "$ENV{'REMOTE_HOST'} - [$date]\n";
  31.    close (LOG);
  32. }
  33.  
  34. exit;
  35.